//
//  NgMacros_h.h
//  NgTopOSShove
//
//  Created by yscompany on 2018/11/19.
//  Copyright © 2018 NgTopOS. All rights reserved.
//

/**
 宏定义文件
 */
#ifndef NgMacros_h_h
#define NgMacros_h_h

/***************************** 常用颜色 **************************/
#define kColorWithRGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1] //传入RGB获得对应的颜色
/***************************** 判断手机操作系统 **************************/
#define ISIOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 10.0)
#define ISIOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 9.0)
#define ISIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0 && [[[UIDevice currentDevice] systemVersion] floatValue] < 8.0)

#define ISMOREIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
#define ISMOREIOS8 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define ISMOREIOS9 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9.0)
#define ISMOREIOS10 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0)
#define ISMOREIOS11 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 11.0)

/***************************** 判断手机型号 **************************/
#define kScreenW [UIScreen mainScreen].bounds.size.width // 屏幕宽度
#define kScreenH [UIScreen mainScreen].bounds.size.height // 屏幕高度

#define iPhone4 (kScreenH == 480) // 判断是否位iPhone4
#define iPhone5 (kScreenH == 568) // 判断是否为iphone5
#define iPhone6 (kScreenH == 667) // 判断是否为iphone6
#define iPhone6plus (kScreenH == 736) // 判断是否为iphone6plus
#define iPhoneX (kScreenH == 812) //判断是否为iPhoneX

// 全面屏（刘海屏）判断
#define infinityScreen (CGRectGetHeight(UIApplication.sharedApplication.statusBarFrame) > 20)

#define ScreenW_rate (kScreenW/375) // 屏幕宽度比例   以iPhone6 为基准
#define ScreenH_rate (kScreenH/667) // 屏幕高度比例   以iPhone6 为基准
//iPhoneX 适配的宏
#define SafeAreaTopHeight (kScreenH == 812 ? 88 : 64)
#define SafeAreaBottomHeight (kScreenH == 812 ? 34 : 0)
#define SafeAreaSearchBarHeight (kScreenH == 812 ? 44 : 20)
#define SafeAreaTabBarHeight (kScreenH == 812 ? 83 : 49)

/***************************** 线条默认宽度 **************************/
#define SINGLE_LINE_WIDTH           (1 / [UIScreen mainScreen].scale)
#define SINGLE_LINE_ADJUST_OFFSET   ((1 / [UIScreen mainScreen].scale) / 2)

/***************************** View 坐标(x,y)和宽高(width,height) **************************/
#define X(v)                    (v).frame.origin.x
#define Y(v)                    (v).frame.origin.y
#define WIDTH(v)                (v).frame.size.width
#define HEIGHT(v)               (v).frame.size.height

#define MinX(v)                 CGRectGetMinX((v).frame)
#define MinY(v)                 CGRectGetMinY((v).frame)

#define MidX(v)                 CGRectGetMidX((v).frame)
#define MidY(v)                 CGRectGetMidY((v).frame)

#define MaxX(v)                 CGRectGetMaxX((v).frame)
#define MaxY(v)                 CGRectGetMaxY((v).frame)

#define RECT_CHANGE_x(v,x)          CGRectMake(x, Y(v), WIDTH(v), HEIGHT(v))
#define RECT_CHANGE_y(v,y)          CGRectMake(X(v), y, WIDTH(v), HEIGHT(v))
#define RECT_CHANGE_point(v,x,y)    CGRectMake(x, y, WIDTH(v), HEIGHT(v))
#define RECT_CHANGE_width(v,w)      CGRectMake(X(v), Y(v), w, HEIGHT(v))
#define RECT_CHANGE_height(v,h)     CGRectMake(X(v), Y(v), WIDTH(v), h)
#define RECT_CHANGE_size(v,w,h)     CGRectMake(X(v), Y(v), w, h)

/***************************** View 圆角 **************************/
#define ViewRadius(View, Radius)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES]

#define ViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setCornerRadius:(Radius)];\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setBorderColor:[Color CGColor]]

#ifdef DEBUG
#   define LOG_INF(fmt,...) NSLog((@"[Information] %s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#   define LOG_INF(...)
#endif



#endif /* NgMacros_h_h */

